package com.atues.thread.threadpool.util;

import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.ThreadFactory;
import java.util.concurrent.atomic.AtomicInteger;

public class NamingThreadFactory implements ThreadFactory {
    private final AtomicInteger threadNum = new AtomicInteger();
    private final String name;

    public NamingThreadFactory(String name) {
        this.name = name;
    }
    @Override
    public Thread newThread(Runnable r) {

        Map<Double,Integer> map = new HashMap<>();

        for(int c: map.values()){
            System.out.println(c);
        }
        Thread t = new Thread(r);
        t.setName(name + "-" + threadNum.incrementAndGet());
        return t;
    }
}
